package com.wgh.api.client.search;

import com.wgh.api.client.fallback.SearchServiceClientFallback;
import com.wgh.common.vo.PageResult;
import com.wgh.common.vo.Result;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Map;

/**
 * 搜索服务完整客户端接口
 * 对应SearchController中的所有API
 */
@FeignClient(name = "shop-search", fallback = SearchServiceClientFallback.class)
public interface SearchServiceClient {

    /**
     * 商品搜索接口
     */
    @GetMapping("/search/products")
    Result<?> searchProducts(
            @RequestParam(required = false) String keyword,
            @RequestParam(required = false) Long categoryId,
            @RequestParam(required = false) Long brandId,
            @RequestParam(required = false) String priceRange,
            @RequestParam(required = false) String sortField,
            @RequestParam(required = false, defaultValue = "desc") String sortOrder,
            @RequestParam(required = false, defaultValue = "1") Integer pageNum,
            @RequestParam(required = false, defaultValue = "20") Integer pageSize,
            @RequestParam(required = false) Map<String, Object> filters);

    /**
     * 获取搜索建议
     */
    @GetMapping("/search/suggestions")
    Result<?> getSearchSuggestions(
            @RequestParam String keyword,
            @RequestParam(required = false, defaultValue = "10") Integer count);

    /**
     * 获取搜索聚合信息
     */
    @GetMapping("/search/aggregations")
    Result<?> getSearchAggregations(
            @RequestParam(required = false) String keyword);

    /**
     * 根据商品ID获取商品详情
     */
    @GetMapping("/search/products/{productId}")
    Result<?> getProductDetail(@PathVariable Long productId);

    /**
     * 重建商品索引
     * 注意：此接口应只允许管理员访问
     */
    @PostMapping("/search/rebuild-index")
    Result<?> rebuildProductIndex();
}